<!DOCTYPE html>
<html lang="en"><html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title th:text="${quesion.title}"></title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/css/communtiy.css">
    <link rel="stylesheet" href="/css/editormd.preview.min.css">

    <script src="https://www.jq22.com/jquery/jquery-2.1.1.js"></script>
    <script src="/js/bootstrap.min.js" type="application/javascript"></script>
    <script src="/js/communtiiys.js" type="application/javascript"></script>
    <script src="/js/moment.js" type="application/javascript"></script>
    <script src="/js/editormd.min.js" type="application/javascript"></script>
    <script src="/js/lib/marked.min.js" type="application/javascript"></script>
    <script src="/js/lib/prettify.min.js" type="application/javascript"></script>



</head>
<body style="background-color: #e2e2e2">
<!--插入表头共同片段-->
<div th:insert="~{navaigation::nav}"></div>
<!--//问题首页-->
<div class="container-fluid main" >
    <div class="row">
        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h3> <span class="quesions-title" th:text="${quesion.title}"></span></h3>
                <span>
                   作者： <span th:text="${quesion.getUsers().getName()}"></span>|
                    阅读数：<span th:text="${quesion.getView_count()}" id="commetn_content"></span> |
                    发布时间：<span th:text="${#dates.format(quesion.getGmt_create(),'yyyy-MM-dd HH:mm')}" style="
margin-right: 30px;"></span>|
                    收藏该篇博客 <span th:id="${quesion.getId()}" class="glyphicon glyphicon-heart isColor" aria-hidden="true" th:if="${isSave=='save'}"
                                 style="color: red" onclick="SaveQueiosns(this)"></span>
                    <span th:id="${quesion.getId()}" class="glyphicon glyphicon-heart isColor" aria-hidden="true" th:if="${isSave!='save'}"
                          style="color:grey" onclick="SaveQueiosns(this)"></span>
                      <span id="likeCount" style="color: red" th:text="${likeCount}"></span>
                    <span id="mes" style="color: red"></span>
            </span>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
               <!---富文本实现展示预览代码-->
                <div  th:id="quseion_views" class="col-lg-12 col-md-12  col-sm-12 col-xs-12">
                    <textarea style="display:none;" th:text="${quesion.getDescription()}"></textarea>
                </div>
                <script type="application/javascript">
                    var testView=editormd.markdownToHTML("quseion_views",{

                    });
                </script>

                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <!--标签-->
                <div  class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    标签：
                    <span class="label label-info quesions-tags2" th:each=" tags:${quesion.getTag().split(',')}">
                        <span class="glyphicon glyphicon-tags"></span>
                        <span class="label label-info" th:text="${tags}"></span>
                    </span>
                </div>

                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <!-- 当当前用户不为空，并且用户的id主键和文章的cretor想等时候在显示编辑，确定当前用户就是这个文章的注入-->
<!--                session.user!=null 先判断这个条件。坑-->
                <div class="col-lg-12 col-md-12  col-sm-12 col-xs-12" th:if="${session.user!=null && session.user.getId()==quesion.getCreator()}">
                    <a class="communtiy-meum" th:href="@{'/publish/'+${quesion.getId()}}">  <span class="glyphicon glyphicon-pencil" aria-hidden="true">
                    </span>编辑文章</a>
                </div>
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-sp">
                <!--回复-->
                <h4>
                    <span th:text="${quesion.comment_count}"></span>个回复
                </h4>
                <!---一级评论--->
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment-sp">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment_section" th:each="commtntList2:${commentList}">
                    <div class="media">
                        <div class="media-left">
                            <a href="#">
                                <img class="media-object img-rounded" th:src="${commtntList2.getUsers().getAvatarUrl()}" style="height: 50px;width: 50px;">
                            </a>
                        </div>
                        <div class="media-body">
                            <h5 class="media-heading" style="padding-top: 10px;">
                             用户： <span th:text="${commtntList2.getUsers().getName()}"></span>
                            </h5>
                            回复内容：<span th:text="${commtntList2.getContent()}"></span>
                            <!--评论其他功能--->
                            <div class="meum">
                                <span class="glyphicon glyphicon-thumbs-up " aria-hidden="true" th:id="${'fsUp-'+commtntList2.getId()}" onclick="clickfsUp(this)"></span>
                                <span th:id="${'FabulousUp-'+commtntList2.getId()}" th:text="${commtntList2.getFabulous_up()}"></span>
                                <span class="glyphicon glyphicon-thumbs-down icon" aria-hidden="true" th:id="${'fsDown-'+commtntList2.getId()}" onclick="clickfsDown(this)"></span>
                                <span th:id="${'FabulousDown-'+commtntList2.getId()}" th:text="${commtntList2.getFabulous_down()}"></span><!--点赞-->
                                <span  th:data-id="${commtntList2.getId()}"
                                       onclick="openSonComment(this)"
                                       class="glyphicon glyphicon-comment icon " aria-hidden="true"></span>
                                <!--   id绑一级评论。便于后面的更新-->
                                <span th:id="${'CommentSonCount-'+commtntList2.getId()}" th:text="${commtntList2.getCommentson_count()}"></span>
                                <span class="pull-right" th:text="${#dates.format(commtntList2.getGmt_create(),'yyyy-MM-dd HH:mm')}"></span>
                            </div>
                            <!--/二级评论根据每个父评论去数据库查找看看有没有字评论、、-->
                            <!--一级评论的id-->
                            <div  th:id="${'comment-'+commtntList2.getId()}" class="sub-comment collapse  col-lg-12 col-md-12 col-sm-12 col-xs-12 appendCommentSon" >
                               <!-- <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 comment_section" th:each="commtntList3:${commentList}">
                                    <div class="media">
                                        <div class="media-left">
                                            <a href="#">
                                                <img class="media-object img-rounded" src="http://a0.att.hudong.com/78/52/01200000123847134434529793168.jpg"  style="height: 50px;width: 50px;">
                                            </a>
                                        </div>
                                        <div class="media-body">
                                            <h5 class="media-heading" style="padding-top: 10px;">
                                                用户： <span th:text="${commtntList3.getUsers().getName()}"></span>
                                            </h5>
                                            回复内容：<span th:text="${commtntList3.getContent()}"></span>
                                            &lt;!&ndash;评论其他功能-&ndash;&gt;
                                            <div class="meum">
                                                <span class="pull-right" th:text="${#dates.format(commtntList3.getGmt_create(),'yyyy-MM-dd HH:mm')}"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>-->
                                <div class="commentSonBtn">
                                    <input type="text" class="form-control" placeholder="输入你的回复内容" th:id="${'input-'+commtntList2.getId()}">
                                    <button type="button" class="btn-success btn" onclick="commentSons(this)" th:data-id="${commtntList2.getId()}">提交评论</button>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <!--  回复输入框-->
                <hr class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="comment_text" th:if="${session.user!=null}">
                    <b><h3 class="comment-sp">回复</h3></b>
                    <div class="media">
                        <div class="media-left">
                            <a href="#">
                                <img class="media-object img-rounded" th:src="${session.user.getAvatarUrl()}"  style="height: 50px;width: 50px;">
                            </a>
                        </div>
                        <div class="media-body">
                            <h4 class="media-heading" style="padding-top: 10px;">
                                姓名：<span th:text="${session.user.getName()}"></span>
                            </h4>
                        </div>
                    </div>
                    <!--回复文本-->
                    <input type="hidden" id="quesionid" th:value="${quesion.getId()}" placeholder="请输入你的回复内容">
                    <!--绑定文章的事件-->
                    <textarea class="form-control comments" rows="6" id="comment_content"></textarea>
                    <button type="button" class="btn-success comment-btn" onclick="postComment()">回复</button>
                </div>
            </div>
        </div>

        <div class="col-lg-3 col-md-12  col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h4><span class="glyphicon glyphicon-user" aria-hidden="true"></span>发起人</h4>
                <div class="media">
                    <div class="media-left">
                        <a href="#">
                            <img class="media-object img-circle" th:src="${quesion.getUsers().getAvatarUrl()}"  style="height: 50px;width: 50px;">
                        </a>
                    </div>
                    <div class="media-body">
                        <h4 class="media-heading" >
                            昵称：<span th:text="${quesion.getUsers().getName()}"></span>
                        </h4>
                        <h4 class="media-heading" th:if="${session.user!=null}">
                            关注博主：<button  th:if="${isGuanzhu=='yes' and session.user.getId()!=quesion.getUsers().getId()}" th:id="${quesion.getUsers().getId()}" onclick="GuanZhu(this)" class="glyphicon glyphicon-plus badge  " aria-hidden="true" >已关注</button>
                            <button  th:if="${isGuanzhu=='no' and session.user.getId()!=quesion.getUsers().getId()}" th:id="${quesion.getUsers().getId()}" onclick="GuanZhu(this)" class="glyphicon glyphicon-plus badge btn btn-mini btn-success" aria-hidden="true" >未关注</button>
                            <span class="guanZhuNumber" style="color: brown;font-size: 5px;" th:text="${fensiCount+'人已关注'}" th:id="${fensiCount}"></span>
                        </h4>
                        <h4>
                            <a th:if="${userIsLogin=='isloging'}" th:href="@{'/othermes/'+${quesion.getUsers().getId()}}">他的个人信息</a>
                        </h4>
                        <h4>
                            <a th:if="${userIsLogin=='isloging'}" th:href="@{'/profile/autor-'+${quesion.getId()}}">查看他的其他帖子</a>
                        </h4>

                    </div>
                </div>
            </div>
            <!---引入图片-->
            <hr class="col-lg-12 col-md-12  col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12  col-sm-12 col-xs-12">
                <img src="/img/mashuaitext.jpg" style="width: 50px;height: 50px;">
            </div>
            <!---与话题相关的问题--->
            <hr class="col-lg-12 col-md-12  col-sm-12 col-xs-12">
            <div class="col-lg-12 col-md-12  col-sm-12 col-xs-12">
                <h3><span class="glyphicon glyphicon-list" aria-hidden="true"></span>与此话题相关的文章</h3>
                <ul class="connect-qeusion">
                    <li th:each="connect:${connectQuesions}">
                        <a th:href="@{'/quesion/'+${connect.getId()}}" th:text="${connect.getTitle()}"></a>
                        <span style="font-size: 5px;color: #999999" class="glyphicon glyphicon-time" aria-hidden="true">
                            <span th:text="${#dates.format(connect.getGmt_create(),'yyyy-MM-dd')}"></span>
                        </span>
                    </li>
                </ul>

            </div>
        </div>
    </div>
</div>
</body>
<script type="application/javascript">
    function GuanZhu(e) {
        //直接获取到这个文章的博主id
        var boZhuId=$(e).attr("id");
        var text=$(e).text();
       $.get("/NewGuanZhu",{"boZhuId":boZhuId,"judegGuanzhu":text},function (data) {

           if(data.mes=='已关注'){
               //说明是从未关注到已经关注
               $(e).text("已关注");
               $(e).removeClass("btn btn-mini btn-success");
           }
           if(data.mes=='未关注'){
               //从没从已关注到未关注
               $(e).text("未关注");
               $(e).addClass("btn btn-mini btn-success");
           }
           $(".guanZhuNumber").empty();
           $(".guanZhuNumber").text(data.fensiCount+"人已经关注");
            console.log(data);
        });
    }

    //搜索
    $(".lianhe_seach").keyup(function (){
        var inputMes =$(".lianhe_seach").val();
        $.get("/searchValue",{"inputMes":inputMes},function (data) {
            console.log(data.length)
            if(data.length!=0){
                $("#apeendChoice").empty();
                for(var i=0;i<data.length;i++){
                    $("#apeendChoice").append("<li><b><a href='#' onclick='getSlectValues(this)' style='color: black;margin-top: 10px;font-size: 15px;'>"+data[i].title+"</a></b></li>" +
                        "<br>")
                }
            }else {
                $("#apeendChoice").append("");

            }
        });


    });
    function getSlectValues(e) {
        var text = $(e).text();
        $(".lianhe_seach").val(text);
    }
</script>
</html>